import java.io.*;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: fzykd
 * Date: 2022-11-10
 * Time: 20:19
 */

//按字节流来读文件
public class Demo3 {
    public static void main1(String[] args) {
        try(InputStream inputStream = new FileInputStream("e:/hade/demo.txt")){
            //使用scanner来读文件 将inpStream对象交给scanner
            Scanner scanner = new Scanner(inputStream);
            String b = scanner.next();
            System.out.println(b);
        }catch (IOException e){
            e.printStackTrace();
        }
    }


    public static void main(String[] args) {
        //使用printWriter来写文件
        try(OutputStream outputStream = new FileOutputStream("e:/hade/123.txt")){
            //写的对象是谁
            PrintWriter printWriter = new PrintWriter(outputStream);
            String b = "你好 这是我写的！";
            //要写的内容
            printWriter.println(b);
            //刷新缓冲区
            printWriter.flush();
        }catch (IOException e){
            e.printStackTrace();
        }
    }
}
